package com.wf.demo;
import com.wf.demo.job.netty.NettyServer;
import com.wf.demo.job.util.PortUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.scheduling.annotation.EnableScheduling;

import java.net.InetSocketAddress;
@Slf4j
@EnableScheduling
@EnableCaching
@SpringBootApplication
public class Application implements CommandLineRunner {
    //1. 增加注解： @EnableCaching 用于启动缓存
    //2. 检查端口6379是否启动。 6379 就是 Redis 服务器使用的端口。如果未启动，那么就会退出 springboot。
    static {
        PortUtil.checkPort(6379,"Redis 服务端",true);
    }
    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
    @Autowired
    private NettyServer nettyServer;

    @Override
    public void run(String... args) throws Exception {
        InetSocketAddress address=new InetSocketAddress("127.0.0.1",7000);  //北斗端口
        InetSocketAddress address2=new InetSocketAddress("127.0.0.1",7001); //5G端口
        log.info("netty服务器启动地址是127.0.0.1");
        nettyServer.start(address,address2);
    }
}